#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> searchRange(vector<int>& nums, int target) {
    int n = nums.size();
    if(n == 0) return {-1, -1};
    int left = 0, right = n - 1;
    // 查找起始位置
    while(left < right)
    {
        int mid = (left + right) / 2;
        if(nums[mid] >= target) right = mid;
        else left = mid + 1;
    }

    // 判断是否存在
    if(nums[left] != target) return {-1, -1};

    // 查找结束位置
    int l = 0, r = n - 1;
    while (l < r)
    {
        int mid = (l + r + 1) / 2;
        if(nums[mid] <= target) l = mid;
        else r = mid - 1;
    }
    return {left, l};
}

int main()
{
    vector<int> nums = {5,7,7,8,8,10};
    // auto ret = searchRange(nums, 8);
    // cout << ret[0] << " " << ret[1] << endl;
    auto it = lower_bound(nums.begin(), nums.end(), 8);
    cout << (it - nums.begin()) << " " ;
    it = upper_bound(it, nums.end(), 8);
    cout << (it - nums.begin() - 1) << endl;
    return 0;
}